#ifndef AFFECTSBIP_T
#define AFFECTSBIP_T

#include <algorithm>
#include "PKB.h"

typedef struct{
	vector<vector<int>> m;
}matrix_t;

class AffectsBip{
private:
	PKB* pkb;
	vector<vector<int>> CFGBip;

	vector<matrix_t> mtx;
	vector<vector<int>> affectsBipMatrix;
	vector<pair<int,int>> affectsBipList;
	vector<vector<int>> affectsBipStarMatrix;
	vector<pair<int,int>> affectsBipStarList;

	StmtTable st;
	VarTable varT;
	vector<int> modifiesMap;
	vector<vector<int>> usesMatrix;
	vector<vector<int>> vModifiedByLine;
	int totalLineNum;

	bool isBipComputed, isBipStarComputed;

	int DealWithAssign(int, vector<int>, matrix_t*);
	while_t findWhileIndexMap(int, vector<int>);
	int DealWithWhile(int, vector<int>, matrix_t*);
	if_t findIfIndexMap(int, vector<int>);
	int DealWithIf(int, vector<int>, matrix_t*);
	vector<vector<int>> mergeVMList(vector<vector<int>>,vector<vector<int>>);

public:
	AffectsBip();
	AffectsBip(PKB*);
	void ComputeAffectsBip();
	void ComputeAffectsBipStar();
	vector<vector<int>> GetAffectsBipMatrix();
	vector<pair<int,int>> GetAffectsBipList();
	vector<vector<int>> GetAffectsBipStarMatrix();
	vector<pair<int,int>> GetAffectsBipStarList();
	bool IsAffectsBipComputed();
	bool IsAffectsBipStarComputed();
};

#endif